Question address: http://poj.org/problem? Id = 3270
Note that some of the requirements_ Int64, The other part is ignored (think it is impossibleInt). ResultWaNowNLong unknown reason.
This is a classic question of reverse order. Beginners. There is one more State than the basic number of reverse orders. That is, you need to write one more query.
# Include
Cow sorting
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 6393
Accepted: 2476
DescriptionFarmer John ' s n (1≤ n ≤10,000) Cows is lined up to being milked in the evening. Each cow have a unique "grumpiness" level in the range 1...100,000. Since Grumpy cows is more likely to damage FJ ' s milking equipment, FJ would like to reorder the cows in line so they is Lined up in increasing order of grumpiness. During This proces
the two policies described above? From the greedy point of view, it cannot be better, so we only need to select a smaller one from the above two strategies. Two calculation schemes are provided:
First strategy: sum1 = (L1 + Min (L) + (L2 + Min (L) +... + (Lm-1 + Min (L) among them: sum1 is the total cost, Li is the number of beef temper in the cycle, except that a very small total of S-1, Min (L) is the temper of the smallest cattle.
Sort out and get: sum1 = sum (L) + (m-2) * Min (L)
Second str
, let 6 return to the loop again. The cost of doing so is obvious:
Sum + min + (LEN + 1) * smallest
Sum is the sum of all the numbers in the cycle, Len is the length, Min is the smallest number in the ring, and smallest is the smallest number in the entire series.
5. therefore, the cost of sorting a loop is sum-min + (LEN-1) * min and sum + min + (LEN + 1) * small number of smallest. However, we do not know how to introduce the two formulas here.
6. When calculating a loop, we do not need
POJ 3270-Cow Sorting (replacement group), poj3270-cow
Address: POJ 3270
Question: There are nheaded cows, each of which has a unique "anger value", to sort their anger values from small to large (the time spent exchanging any two cows for their anger values and), find the minimum exchange time.
Ideas:
1. Locate the initial and end states (the initial states are given by the question, and the end States are
For n given numbers, we can consider any arrangement as a replacement. So for the question poj 3270, let's look at this: first, we will give you an order of n different numbers, and then we will sort these numbers from small to small. The question requires an ascending order. Then we regard the input arrangement as a replacement.
Therefore, any replacement can be expressed by multiplying the replacement ring. Therefore, in order for the number in the
/* For each group, we have two types of hair exchange: 1. in the group for, take the smallest number t in the group and the other each number exchange, a total of K-1 times, the cost is: Sum + (K-2) * t.2. will be the smallest number of the series Minn, pulled into the group, exchange the smallest number of T with the group, then exchange the K-1 with the smallest number of others, and then replace the Minn with the T, which costs: sum + T + (k + 1) * Minn so minimum cost we take the smallest of
cost of doing so is clearly:sum + min + (len + 1) * SmallestSum of all the numbers in this loop. Len is the length,min is the smallest number in the ring, andsmallest is the smallest number in the whole sequence. 5. Thus, the price of a loop is sum-min + (len-1) * min and sum + min + (len + 1) * Smallest Small That number. But here are two formulas that do not yet know how to launch. 6. when we calculate the cycle, we do not need to record all the elements of the cycle, only the smallest numbe
[m];//to[] Record mapping relationships on permutation groups9 Ten intCircleintu) One { A intv = u, ans =0; - intCNT =0; - while(U! =To[v]) { theVIS[V] =1; -cnt++; -Ans = ans+B[v]; -v =To[v]; + } -Ans = ans+b[v], cnt++; +VIS[V] =1; A if(CNT = =1)return 0; at Else{ - /*here to determine whether to use the smallest number of cows to help the loop set the team is not the result of a smaller - the smallest cow added to help is the cow with the value b[1] and the smal
from another loop to enter the loop, making the exchange less expensive. For example, the initial state:1 8 9) 7 6Can be decomposed into two loops:(1) (8 6 9 7), obviously, the second loop is (8 6 9 7) and the smallest number is 6. We can deploy the smallest number 1 of the entire sequence into this loop. Change the second loop to: (8 1 9 7). Let this 1 complete the task, then swap with 6, and let 6 go back to the loop. The cost of doing this is obvious: Sum + min + (len + 1) * SmallestThe sum
, is the interchange of the replacement, and then the addition of the cattle in the order, the cost of small* (len-1) + (sum-min)Then interchange with min, spend Small+minTotal cost small* (len+1) +sum+minTake a minimum of two cases.As for the processing sequence, I sort it out after marking each cow where it should be, and then each permutation is done separately.
The code is as Follows:#include #include #include #include #include #include #include #include #include #include #include #
Integration with IBM Connections Files and IBM Docs is a shiny new feature offered in iNotes9.0. IBM Connections Files is a platform for enterprise-level information sharing and team collaboration. IBM Docs is also an enterprise-class online file editing system. iNotes9.0 and their integration effectively improve the i
From a security perspective, IBM I provides three levels of security protection: physical security, logon security, and resource security. Physical security is from the hardware perspective, primarily involving the protection of IBM I data storage media; Logon security is user-centric, restricting who accesses IBM I and what to do after logging in; Resource secur
In layman's terms, IBM I job management is responsible for handling system requests submitted by users or programs, which is one of the basic functions of the IBM I platform. Unlike Windows and UNIX, there are more concepts around IBM I job management, such as jobs, job descriptors, job queues, subsystems, subsystem descriptors, memory pools, output queues, and s
User authentication is one of the most basic functions to ensure program security for application developers engaged in IBM I platform. As a Java API,IBM Java Toolbox for access and manipulation of data and resources on the IBM I platform, a variety of user authentication strategies are implemented, which can solve the security problems of the program simply and
As a set of Java application programming interfaces for the IBM I platform, IBM Java Toolbox for I is primarily used to access IBM I data and resources. The security of data and application is one of the important factors to be considered in IBM I application developers. By relying on SSL communications between
Original http://blog.csdn.net/ztz0223/article/details/7603041
I have already talked about some modeling operations in IBM RSA (IBM Rational Software Architect) V8 (v8.04). For details, refer to the following link:
One of ibm rsa (IBM Rational Software Architect) V8 learning, installing
Compared with the traditional green screen IBM I applications, many modern IBM I applications are based on web technology, that is, the front-end uses a web-based graphical user interface, back-end reuse of traditional RPG and COBOL business programs. How to realize software reuse is an important goal of IBM I application modernization. On the one hand, the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.